home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
tmdsp
/
troll.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
2KB
|
101 lines
/*
TROLL.C Ver 0.02 1991.08.09 by Y.Kurihara (Nif PDC01620)"
T-MENU の画面にちょっかいを出すプログラム その2
(1) TROLL [<スクロール行数>]
(2) TROLL <X座標> <Y座標> <桁数> <行数> [<スクロール行数>]
(1) 全画面をスクロールする
(2) 指定範囲をスクロールする
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <machine.h>
#define X0 (2)
#define Xl (76)
#define Y0 (7)
#define Yl (20)
#define VRAM( offset ) ( (char far *)MK_FP( 0xc000,( offset ) ) )
#define PORTpage (0xff83)
#define PORTplane (0xff81)
#define Y1page (256)
#define MAXbuff (256)
char buff[ MAXbuff ];
void roll( int x1,int y1,int x2,int y2 )
{
unsigned off;
int x,y;
y1 = y1 *16;
y2 = y2 *16 + 15;
if( y1 < Y1page ) {
outp( PORTpage, 0x00 );
off = y1 * 128 + x1;
} else {
outp( PORTpage, 0x10 );
off = ( y1 - Y1page ) * 128 + x1;
}
x = x2 - x1 + 1;
for( y = y1; y < y2; y++ ) {
if( y == Y1page - 1 ) {
outp( PORTpage, 0x10 );
movedata( 0xc000,x1,FP_SEG(buff),FP_OFF(buff),x );
outp( PORTpage, 0x00 );
movedata( FP_SEG(buff),FP_OFF(buff),0xc000,off,x );
outp( PORTpage, 0x10 );
off = off + 128 - Y1page * 128;
} else {
movedata( 0xc000,off + 128,0xc000,off,x );
off += 128;
}
}
while( --x >= 0 ) {
*VRAM( off + x ) = 0xff;
}
return;
}
main( int argc,char **argv )
{
int save_page;
int save_plane;
int x1 = X0;
int y1 = Y0;
int x2 = Xl;
int y2 = Yl;
int n = 1;
if( argc >= 6 ) {
x1 = atoi( argv[1] );
y1 = atoi( argv[2] );
x2 = atoi( argv[3] );
y2 = atoi( argv[4] );
n = atoi( argv[5] );
} else if( argc >= 2 ){
n = atoi( argv[1] );
}
if( x1 < 0 || y1 < 0 || x2 < 1 || y2 < 1 ) exit(1);
if( x1 >= 80 || y1 >= 30 ) exit(1);
if( ( x2 = x1 + x2 - 1 ) >= 80 ) x2 = 79;
if( ( y2 = y1 + y2 - 1 ) >= 30 ) y2 = 29;
n = n * 16;
save_page = inp( PORTpage );
save_plane = inp( PORTplane );
outp( PORTplane,15 );
while( n-- > 0 ) roll( x1,y1,x2,y2 );
outp( PORTpage, save_page );
outp( PORTplane, save_plane );
exit( 0 );
}